package com.github.binarywang.demo.wx.mp.utils;

import java.util.HashMap;

/**
 *
 */
public class StorageUtils {
    private final static HashMap<String, Object> redis = new HashMap<String, Object>();

    public static String put(String key, Object v) {
        // 模拟存储到redis,也可以存储到mysql表中.
        if (!redis.containsKey(key)) {
            redis.put(key, v);
            return key;
        }
        throw new RuntimeException("key已存在!");
    }

    public static Object get(String key) {
        return redis.get(key);
    }
    public static String getStr(String key) {
        Object o = redis.get(key);
        if (o != null) {
            return o.toString();
        }
        return null;
    }
}
